/*
 * Copyright (c) 2006, 2021, webrx.cn All rights reserved.
 *
 */
package cn.imgs;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

/**
 * <p>Project: javaseapp - Img10
 * <p>Powered by webrx On 2021-08-16 11:02:02
 * <p>Created by IntelliJ IDEA
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 16
 */
public class Img11 {
    public static void main(String[] args) throws IOException {
        //原图
        var src = ImageIO.read(new File("images/office.jpg"));

        //裁剪图的宽度，高度及类型
        int dw = 104;
        int dh = 154;
        int dt = BufferedImage.TYPE_INT_ARGB;
        var dst = new BufferedImage(dw, dh, dt);
        var g = dst.createGraphics();
        //裁剪图的坐标位置
        int x = 179;
        int y = 88;
        g.drawImage(src, 0, 0, dw, dh, x, y, x + dw, y + dh, null);
        //保存裁剪后的结果
        ImageIO.write(dst, "png", new File("images/offcie_ok.png"));
    }

}
